#ifndef MOUSEDRAGGRAPHICS_H
#define MOUSEDRAGGRAPHICS_H

#include <QWidget>
#include <QPoint>
#include <QPainter>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QEvent>
#include <iostream>
#include <QGraphicsItem>
#include <QColor>



QT_BEGIN_NAMESPACE
namespace Ui { class MouseDragGraphics; }
QT_END_NAMESPACE

class MouseDragGraphics : public QWidget
{
    Q_OBJECT

public:
    MouseDragGraphics(QWidget *parent = nullptr);
    ~MouseDragGraphics();

public slots:
    void setDrawing(bool isDrawing) {m_isDrawing = isDrawing;};

private:
    Ui::MouseDragGraphics *ui;

    bool m_mouseIsPressed = false;
    bool m_isDrawing = false;
    QPoint m_startPoint, m_endPoint;    //起始点和终止点
    QPainter *m_painter;
    QColor m_penColor = QColor(174, 214, 241);
    QColor m_brushColor = QColor(174, 214, 241, 100);

    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;
    virtual void paintEvent(QPaintEvent *event) override;
};
#endif // MOUSEDRAGGRAPHICS_H
